/*
 * Copyright 2011-2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sabayframework.mem;

/**
 * Memorizable objects should implement this interface and, additionally,
 * have a public default constructor for instantiation by the framework. 
 * Default constructor must create an empty object that indicates absence of 
 * data in space.   
 * @author Alex Antonau
 * */
public interface Memorizable {

	/** 
	 * Returns unique id of this memorizable object.
	 * */
	long getId();
	
	/** 
	 * Sets unique id of this memorizable object.
	 * */
	void setId(long id);
	
	/**
	 * Reads content of this memorizable object from given buffer.
	 * */
	void deserialize(BigBuffer serialized);
	
	/**
	 * Writes content of this memorizable object to given buffer.
	 * Object id can be omitted.
	 * */
	void serialize(BigBuffer serialized);
	
	/**
	 * Returns maximum size of a buffer for this object.
	 * @return number of bytes enough to serialize this object.
	 * */
	int getMaxBufferSize();
}
